/* $Header: keyboard.h,v 2.6 03/07/10 11:24:04 przybyls Exp $ */

/***********************************************************************/
/* INCLUDE FILE NAME: keyboard.h                                       */
/* ==================                                                  */
/*                                                                     */
/* Author: Tom Przybylski                                              */
/*                                                                     */
/* COMMENT: .h file for stuff in keyboard directory.                   */
/*                                                                     */
/***********************************************************************/

#ifndef KEYBOARD_H
#define KEYBOARD_H

/*****************************/
/*   IFDEFS                  */
/*****************************/


/*****************************/
/*   SYMBOLIC CONSTANTS      */
/*****************************/

#define KEY_Q_SIZE 50       /* Make sure this agrees with iomap.hs */


#define S_DEFAULT               0   /* State Definitions: They MUST match */
#define S_NUMBER_BUILD          1   /*  the indices of the states in the  */
#define S_OVEN_TEMP             2   /*  State_Table[] array in tables.c   */
#define S_INLET_TEMP            3
#define S_DET_NUM               4
#define S_CONFIG                5
#define S_NUMBER                6
#define S_COL_SOURCE            7
#define S_COL_OUTLET            8
#define S_VACUUM_ON_OFF         9
#define S_PID                   10
#define S_STATUS                11
#define S_CON_STATUS            12
#define S_SIG_TYPE              13
#define S_SIG_BUILD1            14
#define S_SIG_BUILD2            15
#define S_SIG_BUILD3            16
#define S_SIG_ONOFF             17
#define S_VALVE                 18
#define S_AUX                   19
#define S_AUX_TEMP              20
#define S_COMP_ENTER            21
#define S_COMP_DET              22
#define S_CRYO                  23
#define S_RAMP                  24
#define S_MODE                  25
#define S_MODE_BUILD            26
#define S_LOCK                  27
#define S_OPTION                28
#define S_STOPWATCH             29
#define S_LOAD_STORE            30
#define S_METHOD                31
#define S_METHOD_ENTER          32
#define S_METHOD_TABLE          33
#define S_METHOD_CLEAR          34
#define S_TIME_PROG             35
#define S_VALUE_PROG            36
#define S_SIG_DEF_PROG          37
#define S_PROG_ON_OFF           38
#define S_DELETE                39
#define S_DELETE_ENTER          40
#define S_RT_ONE_LINE           41
#define S_DIAGNOSTIC            42
#define S_MUX_DIAG              43
#define S_ONE_DIGIT             44
#define S_FRONT_BACK            45
#define S_DET_DIAG_ON_OFF       46
#define S_CON_SIG               47
#define S_TEST                  48
#define S_PLOT_MEMORY           49
#define S_HEX                   50
#define S_CON_VALVE             51
#define S_CALIB                 52
#define S_CON_INST_ONOFF        53
#define S_CAL_INLET_ONOFF       54
#define S_CON_AUX               55
#define S_CAL_AUX_ONOFF         56
#define S_CAL_DET_ONOFF         57
#define S_COL_PRES_ONOFF        58
#define S_COL_FLOW_ONOFF        59
#define S_CAL_DELETE            60
#define S_CAL_DELETE2           61
#define S_CT_PROG               62
#define S_CT_ON_OFF             63
#define S_CT_ONE_LINE           64
#define S_ALS_NUMBER            65
#define S_LOGIC                 66
#define S_SEQ_METHOD            67  /* FIRST sequence state */
#define S_SEQUENCE              68  /* used by IsSequenceState(state) fn */
#define S_SEQ_TABLE             69  /* These states must be kept grouped */
#define S_SEQ_ENTER             70  /* together with the first & last    */
#define S_SEQ_CLEAR             71  /* matching that used in fn          */
#define S_SEQ_NUMBER            72
#define S_TWO_NUMBERS           73  /* Sequence ONLY! */
#define S_SEQ_CONTROL           74
#define S_SEQ_PRIORITY          75
#define S_SEQ_REPEAT            76
#define S_SEQ_MODE              77  /* LAST sequence state */
#define S_OFF_ONLY              78
#define S_RICK_KEYS             79
#define S_FIRST_DOT             80
#define S_DOT_NUMBER            81
#define S_DOT_PID               82
#define S_DOT_DECIMAL           83
#define S_DOT_DECIMAL2          84
#define S_SERIAL_1              85
#define S_SERIAL_2              86
#define S_SERIAL_MODIFY         87
#define S_DET_ON_OFF_DEL        88
#define S_PNEU_DIAG_ON_OFF      89
#define S_CT_FRONT_BACK         90
#define S_DEFAULT_METHOD_1      91
#define S_DEFAULT_METHOD_2      92
#define S_DIAG_DEFAULT          93
#define S_DIAG_OPTION           94
#define S_DOT_DIAG_1            95
#define S_DOT_DIAG_2            96
#define S_DOT_DIAG_NUM_1        97
#define S_DOT_DIAG_NUM_2        98
#define S_DOT_DIAG_NUM_MODIFY   99
#define S_OVEN_TYPE_1           100
#define S_OVEN_TYPE_2           101
#define S_OVEN_TYPE_MODIFY      102
#define S_CON_AUX_CRYO          103
#define S_CON_INLET             104
#define S_LAN_ADDR              105
#define S_LAN_ADDR_BUILD        106
#define S_LAN_MODE              107
#define S_ALS_MODE              108
#define S_BOOTP_ON_OFF          109
#define S_SERVICE_COUNTER       110
#define S_REBOOT                111


#define DEL_OVEN_CAL            1
#define DEL_F_INLET_CAL         2
#define DEL_B_INLET_CAL         3
#define DEL_F_DET_CAL           4
#define DEL_B_DET_CAL           5
#define DEL_AUX_CAL             6


#define  TEMP_ONOFF            1  /* These used by r_det.c and r_configdet.c */
#define  GAS1_ONOFF            2
#define  GAS2_ONOFF            3
#define  GAS3_ONOFF            4
#define  FLAME_ONOFF           5
#define  DET_ONOFF             6
#define  TCD_ONOFF             7
#define  TCD_POLARITY          8
#define  ECD_TARGET_ONOFF      9
#define  NPDBEAD_ONOFF         10
#define  NPDTARGET_ONOFF       11
#define  FPDFLAME_ONOFF        12

#define  CONTROL1_ONOFF        13
#define  CONTROL2_ONOFF        14
#define  CONTROL3_ONOFF        15
#define  CONTROL4_ONOFF        16
#define  CONTROL5_ONOFF        17
#define  CONTROL6_ONOFF        18
#define  CONTROL7_ONOFF        19
#define  CONTROL8_ONOFF        20

#define  OEMCTRL1_ONOFF        21
#define  OEMCTRL2_ONOFF        22
#define  OEMCTRL3_ONOFF        23
#define  OEMCTRL4_ONOFF        24
#define  OEMCTRL5_ONOFF        25

#define  OEMXTRL6_ONOFF        26
#define  OEMXTRL7_ONOFF        27
#define  OEMXTRL8_ONOFF        28

#define  OEMXTRL9_ONOFF        29
#define  OEMXTRL10_ONOFF       30

#define  GLOW_ONOFF            31
#define  LDID_ONOFF            32

/*****************************/
/*   MACROS                  */
/*****************************/


/*****************************/
/*   TYPEDEFS                */
/*****************************/

/* NOTE: Hardware keycodes must be < 128 as we use bit 7 to flag   */
/*  that a key is being sent via data comm rather than a "real"    */
/*  keypress                                                       */
typedef enum {  NO_KEY          =  0,
                STOP_KEY        =  2,
                PREP_RUN_KEY    =  4,
                START_KEY       =  5,  /* Must agree with iomap.hs */
                OVEN_KEY        =  7,
                F_INLET_KEY     =  8,
                COLUMN1_KEY     =  9,
                F_DET_KEY       = 10,
                SIGNAL1_KEY     = 11,
                COL_COMP1_KEY   = 12,
                AUX_KEY         = 13,
                B_INLET_KEY     = 14,
                COLUMN2_KEY     = 15,
                B_DET_KEY       = 16,
                SIGNAL2_KEY     = 17,
                COL_COMP2_KEY   = 18,
                TEMP_KEY        = 19,
                PRES_KEY        = 20,
                FLOW_KEY        = 21,
                DET_CONTROL_KEY = 23,
                RAMP_KEY        = 24,
                STATUS_KEY      = 25,
                MODE_TYPE_KEY   = 27,
                INFO_KEY        = 28,
                CLEAR_KEY       = 29,
                UP_ARROW_KEY    = 30,
                TIME_KEY        = 31,
                ON_KEY          = 33,
                ENTER_KEY       = 34,
                DOWN_ARROW_KEY  = 36,
                POST_RUN_KEY    = 37,
                OFF_KEY         = 39,
                SEVEN_KEY       = 40,
                EIGHT_KEY       = 41,
                NINE_KEY        = 42,
                RUN_LOG_KEY     = 43,
                FRONT_KEY       = 45,
                FOUR_KEY        = 46,
                FIVE_KEY        = 47,
                SIX_KEY         = 48,
                OPTION_KEY      = 49,
                BACK_KEY        = 51,
                ONE_KEY         = 52,
                TWO_KEY         = 53,
                THREE_KEY       = 54,
                CONFIG_KEY      = 55,
                DELETE_KEY      = 57,
                ZERO_KEY        = 58,
                RADIX_KEY       = 59,
                MINUS_KEY       = 60,
                LOAD_KEY        = 61,
                METHOD_KEY      = 62,
                TIME_PROG_KEY   = 63,
                F_INJECTOR_KEY  = 64,
                VALVE_KEY       = 65,
                SEQ_CTRL_KEY    = 66,
                STORE_KEY       = 67,
                SEQ_KEY         = 68,
                CLOCK_PROG_KEY  = 69,
                B_INJECTOR_KEY  = 70,
                TRAY_KEY        = 71,
                ADAPT_METH_KEY  = 72,

                START_LOCK_KEY  = 126,   /* Must agree with iomap.hs */
                SUPER_CLEAR     = 127    /*Fake key for data comm */

             } KEYCODE;


typedef enum {  G_NULL          =  0,
                G_NUMBER        =  1,
                G_ON_OFF        =  2,
                G_FRONT_BACK    =  3,
                G_UP_DOWN       =  4,
                G_START_STOP    =  5,
                G_ENTER         =  6,
                G_CLEAR         =  7,
                G_OVEN          =  8,
                G_INLET         =  9,
                G_DETECTOR      = 10,
                G_FLOW          = 11,
                G_PRESSURE      = 12,
                G_STATUS        = 13,
                G_CONFIG        = 14,
                G_COLUMN        = 15,
                G_PREP_RUN      = 16,
                G_DELETE        = 17,
                G_RUN_LOG       = 18,
                G_SIGNAL        = 19,
                G_POST_RUN      = 20,
                G_AUX           = 21,
                G_VALVE         = 22,
                G_INFO          = 23,
                G_TIME          = 24,
                G_ACCELERATOR   = 25,
                G_RAMP          = 26,
                G_MODE          = 27,
                G_LOAD_STORE    = 28,
                G_METHOD        = 29,
                G_AUTO_INJ      = 30,
                G_TRAY          = 31,
                G_ADAPT_METHOD  = 32,
                G_COL_COMP      = 33,
                G_SEQ           = 34,
                G_SEQ_CTRL      = 35,
                G_OPTION        = 36,
                G_TIME_PROG     = 37,
                G_CLOCK_PROG    = 38,

                G_EXIT_DIAG     = 125,   /* Exit diagnostics and then */
                                         /* use default state table   */
                G_USE_DEFAULT   = 126,   /* Use default state table   */
                G_STOP_HERE     = 127    /* Stop group search here    */
             } GROUP;


typedef enum {  STAY            =  0,
                UP              =  1,
                DOWN            =  2
             } DIRECTION;

typedef enum
{
   DET_PRES_SIGNAL,
   DET_FLOW_SIGNAL,
   DET_GAS_STATUS,
   DET_PRES_SEL,
   DET_FLOW_SEL,
   DET_GAS_GLP,
   MAN_DET_GAS_GLP,
   PNEU_GAS_TYPE_SEL,
   PNEU_GAS_TYPE_TITLE,
   PNEU_GAS_SENSOR_TITLE,
   PNEU_GAS_CONTROL_TITLE

} DET_GAS_MSG_TYPE;

typedef struct
   {
      U_INT8 Width;
      U_INT8 Scale;
      void (* Enter)(void);

   }NUMBER_TBL;

typedef const NUMBER_TBL *pNUMBER_TBL;


typedef struct
   {
      GROUP  Group;
      U_INT8 State;
      void (* Rule)(void);

   }STATE_TBL_ENTRY;


typedef enum {  NOT_PRESENT     =  0,
                PASSIVE         =  1,
                ACTIVE          =  2,
                END_TABLE       =  3
             } PRESENCE;


typedef enum {  DISABLE_SC      =  0,
                ENABLE_SC       =  1,
                TEMP_SC         =  2,
                PRES_SC         =  3,
                FLOW_SC         =  4,
                DET_CTRL_SC     =  5,
                RAMP_SC         =  6,
                MODE_SC         =  7
             } SHORTCUT;


typedef enum {  DISABLE_MODE    =  0,
                ENABLE_MODE     =  1
             } MODE_CTRL;


typedef struct
   {
      PRESENCE (* PresenceFn)(void);
      void     (* LineFn)    (LINE line);
      void     (* HelpFn)    (void);
      NUMBER_TBL  Number_Tbl;
      U_INT8   State;
      BIT8     Position;
      BIT8     Index;
      BIT8     Shortcut;
   }SETPT_TBL_ENTRY;

typedef const SETPT_TBL_ENTRY *pSETPT_TBL_ENTRY;


typedef struct
   {
      PRESENCE (* PresenceFn)(void);
      void     (* LineFn)    (LINE line);
      BIT8     Mode;
      BIT8     Index;

   }MODE_TBL_ENTRY;

typedef const MODE_TBL_ENTRY *pMODE_TBL_ENTRY;



typedef struct
   {
      KEYCODE Key;
      U_INT8  State;
      BIT8    Position;
      BIT8    Mode;
      BIT16   Index;
      BIT8    Refresh_On;
      INT8    Scroll_Num;
      U_INT8  Line;           /* 0, .., 3 */
      U_INT16 Window[4];      /* U_INT16 for fn scroll (status key) */
      void    (* Rule)(void);
      void    (* HelpFn) (void);
      void    (* ScrollFn) (DIRECTION direction);
      pSETPT_TBL_ENTRY Setpt_Tbl;
      pMODE_TBL_ENTRY  Mode_Tbl;

   }STATE;


/*****************************/
/*   EXTERNALS               */
/*****************************/

extern  KEYCODE      Key_Q[KEY_Q_SIZE];
extern  KEYCODE      *Key_Q_Head;
extern  KEYCODE      *Key_Q_Tail;
extern  RESOURCE     Key_Q_Resource;

extern  STATE        Active_State;
extern  STATE        Last_State;
extern  STATE        Return_State;
extern  STATE        Last_Diag_State;

extern  NUMBER_TBL   ALS_Numbers;

extern  PRESENCE  (*PresenceFn) (void);
extern  void      (*DisplayFn)  (LINE line);
extern  U_INT8    (*StateFn)    (U_INT8 index, U_INT8 line);

extern  pNUMBER_TBL  Number_Tbl;
extern  U_INT8       Minus;
extern  U_INT8       Radix;
extern  U_INT8       Digits;
extern  U_INT8       Radix_Digits;
extern  BIT8         Range_Mode;
extern  BIT8         Accum2_Valid;
extern  INT32        Accumulator;
extern  INT32        Accumulator2;

extern  BIT8         Presence_Position;
extern  BIT16        Presence_Index;
extern  BIT8         Presence_Mode;
extern  BIT8         Current_Mode;

extern  BIT8         Number_Image[];
extern  U_INT8       Refresh_Count;
extern  BIT8         Force_Refresh;
extern  BIT8         Skip_Scroll;
extern  BIT8         From_Data_Comm;
extern  BIT8         Info_Displayed;
extern  BIT8         Kill_Scroll_Stay;

extern  KEYCODE      LSD_Key;
extern  KEYCODE      Sig_Key;

extern  INT8         Seq_Toggle;
extern  INT8         Status_Toggle;
extern  INT8         Method_Toggle;
extern  INT8         Status_Index;
extern  U_INT16      Warning_Index;
extern  U_INT16      Method_Warning_Index;
extern  U_INT16      Fault_Index;
extern  U_INT16      Line_Index_16[4];

extern  BIT8         Timeout_Error;

extern  BIT8         StopwatchRunning;
extern  U_INT32      Stopwatch;

extern  U_INT32      Error_Timer;

extern  const SETPT_TBL_ENTRY Oven_Setpt_Tbl[];
extern  const SETPT_TBL_ENTRY Service_Tbl[];
extern  const SETPT_TBL_ENTRY Calib_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY F_OEMDet_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY B_OEMDet_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY Col_1_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY Col_2_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_Calib_Tbl[];
extern  const SETPT_TBL_ENTRY Config_Inst_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_3_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_4_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_5_Tbl[];
extern  const SETPT_TBL_ENTRY Col1_Setpt_Tbl[];
extern  const SETPT_TBL_ENTRY Col2_Setpt_Tbl[];

/* Diagnostics tables */
extern  const SETPT_TBL_ENTRY Diagnostics_Tbl[];
extern  const SETPT_TBL_ENTRY Hidden_Pneu_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Hidden_Det_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Hidden_F_Det_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Hidden_B_Det_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Comm_Tbl[];
extern  const SETPT_TBL_ENTRY Electronics_Tbl[];
extern  const SETPT_TBL_ENTRY Mux_Adc_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Pneumatics_Bd_Tbl[];
extern  const SETPT_TBL_ENTRY Pneumatics_Mux_Adc_Tbl[];
extern  const SETPT_TBL_ENTRY Signal_Dsp_Tbl[];
extern  const SETPT_TBL_ENTRY Test_Tbl[];
extern  const SETPT_TBL_ENTRY Comm_Tests_Tbl[];
extern  const SETPT_TBL_ENTRY Power_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Signal_Diag_Tbl[];
extern  const NUMBER_TBL      Sel_Plot_Mem_Tbl;
extern  const SETPT_TBL_ENTRY Inst_Stat_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Inst_Diag_Config_Tbl[];
extern  const SETPT_TBL_ENTRY LAN_Stat_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY LAN_Diag_Config_Tbl[];
extern  const SETPT_TBL_ENTRY Thermal_Pid_Tbl[];
extern  const SETPT_TBL_ENTRY Pid_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Front_Det_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Back_Det_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Front_Det_Bd_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Back_Det_Bd_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Module_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Module_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Fuel_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Util_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Makeup_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Fuel_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Util_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Makeup_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Fuel_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Util_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Mkup_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Fuel_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Util_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Mkup_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Fuel_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Util_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY F_Det_Mkup_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Fuel_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Util_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Det_Mkup_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_Module_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_3_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_3_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_3_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_4_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_4_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_4_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_5_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_5_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY Aux_5_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY Pneu_Dsp_Editor_Tbl[];
extern  const SETPT_TBL_ENTRY Eeprom_Editor_Tbl[];
extern  const SETPT_TBL_ENTRY F_SS_Valve_Tbl[];
extern  const SETPT_TBL_ENTRY B_SS_Valve_Tbl[];
extern  const SETPT_TBL_ENTRY F_SS_Valve_Tbl[];
extern  const SETPT_TBL_ENTRY B_SS_Valve_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Diag_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Flow_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Flow_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Control_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_SS_Vlv_Control_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Flow_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_SS_Vlv_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Pres_Control_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Flow_Control_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Module_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Module_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Pres_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY F_Inlet_Flow_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY B_Inlet_Flow_Sensor_Tbl[];
extern  const SETPT_TBL_ENTRY BI_Purge_Reg_Tbl[];
extern  const SETPT_TBL_ENTRY FI_Purge_Reg_Tbl[];

/*****************************/
/*   FUNCTION PROTOTYPES     */
/*****************************/

void InitializeKeyboard (void);
void ResetIfClearKey (void);    /* assembly fn */
void KeyboardDriver (void);     /* assembly fn */

void EnableErrorTimeout (void);

void RuleNumberBuild (void);
void RuleInitNumber (void);
void RuleInitNumberRange (void);
void RuleOven (void);
void RuleInlet (void);
pINLET_STATUS WhatInlet (void);
pINLET_STATUS LineWhatInlet (LINE line);
pINLET_STATUS PresenceWhatInlet (void);
void RuleInletOnOff (void);
void RuleDetector (void);
pDETECTOR_STATUS WhatDet (void);
pDETECTOR_STATUS LineWhatDet (LINE line);
pDETECTOR_STATUS PresenceWhatDet (void);
void RuleDetOnOff (void);
void RuleDetDelete (void);
void RuleInitDisplay (void);
void RuleScroll (void);
void RuleConfigTime (void);
void RuleConfigSignal (void);
void RulePrepRun (void);
void RuleThermalPID (void);
void RuleInitPIDMode(void);
void RuleInitDotPIDMode(void);
void RuleStatus (void);
void RuleStatusToggle (void);
void PowerOnDisplay (void);
void RevisionLine( LINE line );
void SignalBuildLine (LINE line);
void RuleSigBuildInit(void);
void RuleSigBuildMinus(void);
void RuleSigBuildLast(void);
void RulePostRun(void);
void RuleValve(void);
void RuleShortCut(void);
void RuleRampShortCut(void);
void RuleInitMode(void);
void RuleMode(void);
void RuleInfo(void);
void RuleInfoNoStateBackup(void);
void RuleTime(void);
U_INT32 GetDateString (INT8 month);
void RuleStopwatch(void);
void RuleDeleteRTLine(void);
void RuleDeleteCTLine(void);
void RuleDelete(void);
void RuleDeleteOneLine(void);
void RuleDiagnostic(void);
void RuleDiagOption(void);
void RuleMuxDiagnostic(void);
void RuleOneDigitNumber(void);
void RuleFrontBack(void);
void RuleInjector(void);
void RuleConfigInjector(void);
void RuleDetInputOnOff(void);
void RuleTest(void);
void RuleInitHexNumber(void);
void RuleHexNumberBuild(void);
void RuleConfigValveSelect (void);
void RuleConfigValve (void);
void RuleNegativeLogic (void);
void RuleDeleteCalib (void);
void RuleAlsInitNumber (void);
void RuleAlsOnOff (void);
void RuleAlsFrontBack (void);
void RuleBootpOnOff (void);
void RuleReboot (void);
void RuleSeqControl (void);
void RuleSeqCtrlEnter (void);
void RuleBackOnly (void);
void RuleOffOnly (void);
void RuleDotOnly (void);
void RuleDotPID (void);
void RuleDotDiag(void);
void RuleDotDiagNum (void);
void RuleHopeYouKnowWhatYouAreDoing (void);
void RuleAdaptMethod (void);
void RulePneuDiagOnOff(void);
void RuleInitLanAddr (void);
void RuleLanAddrBuild (void);
void RuleLanWarn (void);
void RuleAlsWarn (void);

void ScrollModeTable (DIRECTION direction);
void InitModeTable (pMODE_TBL_ENTRY table);
void StackModeTable (pMODE_TBL_ENTRY table);
void InitSetpointTable (pSETPT_TBL_ENTRY table);
void InitSetpointTableAtIndex (pSETPT_TBL_ENTRY table, U_INT8 index);
void InitSetpointTableAtTop (pSETPT_TBL_ENTRY table, U_INT8 index);
void ScrollDown (void);
void ScrollUp (void);
void ScrollStay (void);
void GetOneDigitNumber(pNUMBER_TBL number_tbl);
void GetFrontBack(pNUMBER_TBL number_tbl);

void EnableWatchMode (void);
void DisableWatchMode (void);

INT8 WhatDigit (void);

BIT8 NoKbdDcLock (void);        /* TRUE = NO Keyboard or Datacomm lock */
BIT8 NoKbdDcDeleteLock (void);  /* TRUE = NO Keyboard or Datacomm lock (Delete key) */
BIT8 NoDataCommLock (void);     /* TRUE = NO Data Comm lock            */
BIT8 IfKbdDcLocked (void);      /* TRUE = LOCKED; No messages          */

void NoSeqInfo (void);
void DeleteInfo (void);

void FrontDetDiagLine (LINE line);
void BackDetDiagLine (LINE line);

PRESENCE SetptPresence (U_INT8 index);
PRESENCE AlwaysActive (void);
PRESENCE EndTable (void);
PRESENCE ActiveIfEpcDet (void);
PRESENCE ActiveIfNPD (void);
PRESENCE ActiveIfModule (void);
PRESENCE IfFrInjector (void);
PRESENCE IfBkInjector (void);
PRESENCE IfTray (void);

pSETPT_TBL_ENTRY GetFrontDetTbl (void);
pSETPT_TBL_ENTRY GetBackDetTbl (void);
pSETPT_TBL_ENTRY GetFrontInletTbl (void);
pSETPT_TBL_ENTRY GetBackInletTbl (void);

void ReturnToInstStatDiagLine (void);
void ReturnToLANStatDiagLine (void);
void ReturnToPneuDiagLine (void);
void ReturnToFDetDiagLine (void);
void ReturnToBDetDiagLine (void);
void ReturnToAuxPresDiagLine (void);
void ReturnToMuxAdcDiagLine (void);
void ReturnToPidDiagLine (void);
void ReturnToPowerDiagLine (void);
void ReturnToCommDiagLine (void);
void ReturnToElecDiagLine (void);
void ReturnToSignalDiagLine (void);
void ReturnToAnalogLoopBackLine (void);

void ReturnToFInletDiagLine (void);
void ReturnToBInletDiagLine (void);

void PneuModuleOptLine ( LINE line );
void PresSensorOptLine ( LINE line );
void FlowSensorOptLine ( LINE line );
void PresControlOptLine ( LINE line );
void ModuleBuildDateLine( LINE line );
void TransferModuleSerialNo( LINE line, INT32 serial_no );
void ModuleTestStationIDLine( LINE line );
void ModuleFaultCauseLine( LINE line );
PRESENCE IfModuleFault (void);


#pragma SECTION PROG=rom3

void RuleAux(void);
void RuleAuxOnOff(void);
void RuleCalib (void);
void RuleCalibOnOff (void);
void RuleCalAuxOnOff (void);
void RuleCalDetOnOff (void);
void RuleCalInletOnOff (void);
void RuleClearToLastState(void);
void RuleClearToReturnState(void);
void RuleClearErrorOrReturn(void);
void RuleClearToStatus(void);
void RuleClearToValveLine(void);
void RuleClearToAuxLine(void);
void RuleClearToPowerOn(void);
void RuleClearToLoadStoreDelete(void);
void RuleClearToMethodTbl(void);
void RuleClearToSeqTbl(void);
void RuleClearToDelete(void);
void RuleColComp(void);
void RuleColumnSource (void);
void RuleColumnOutlet (void);
void RuleVacuumOnOff (void);
void RuleConfigAux (void);
void RuleConfigAuxOnOff (void);
void RuleConfigColumn (void);
void RuleConfigDet (void);
void RuleConfigInlet (void);
void RuleConfigInstOnOff (void);
void RuleConfigOven(void);
void RuleCryoOnOff(void);
void RuleColumn (void);
void RuleColPresOnOff (void);
void RuleColFlowOnOff (void);
void RuleOption(void);
void RuleServiceCount (void);
void RuleKeyboardLock(void);
void RuleSignal(void);
void RuleSigBuildEnter(void);
void RuleSignalOnOff(void);
void RuleSequence (void);
void RuleSequenceToggle (void);
void RuleSeqMethodOnOff (void);
void RuleSeqPriorityOnOff (void);
void RuleSerialDot (void);
void RuleInitSerialMode (void);
void RuleOvenTypeDot (void);
void RuleInitOvenTypeMode (void);
void RuleRepeatSeqOnOff (void);
void RuleTimeProg(void);
void RuleSigDefMode(void);
void RuleProgOnOff(void);
void RuleTimeMode(void);

void ScrollClearError (void);
void SetupReturnState (void);
void IgnoreKey (void);
void InitNoScrollRule (void (*helpfn) (void));
void GoToState (U_INT8 state);

void InitFnScroll (PRESENCE (*presence)(void), void (*display)(LINE line),
                   void (*help)(void), INT8 scroll_num);
void InitProgScroll (PRESENCE (*presence)(void), void (*display)(LINE line),
                     void (*help)(void),
                     U_INT8 (*state)(U_INT8 index, U_INT8 line) );
void JumpToProgEntry (U_INT8 index, U_INT8 line);


/* r_signal.c */
void SignalTypeTitle (LINE line);
void SignalValueLine( LINE line );
void SignalTypeLine(LINE line);
PRESENCE IfFrEpcDet1( void );
PRESENCE IfFrEpcDet2( void );
PRESENCE IfFrEpcDet3( void );
PRESENCE IfBkEpcDet1( void );
PRESENCE IfBkEpcDet2( void );
PRESENCE IfBkEpcDet3( void );

void CalibDateLine (DATETIME when, LINE line);
void ModeGasSelectLine (LINE line);
void SerialNoLine( LINE line );

/* Set serial number routines */
void EnterSerialNo (void);

BIT8 GetSignal (void);
BIT8 AnyGSV (void);
BIT8 AnyInjector (void);

void NoAuxInfo (void);
void FlowCalAtInfo (void);
void PresCalAtInfo (void);
void SeqLockedInfo (void);
void SerialNoInfo  (void);

pAUX_STATUS   WhatAuxPres (void);
pAUX_STATUS   LineWhatAuxPres (LINE line);
pAUX_STATUS   PresenceWhatAuxPres (void);

pCOLUMN_STATUS WhatColumn (void);
pCOLUMN_STATUS LineWhatColumn (LINE line);
pCOLUMN_STATUS PresenceWhatColumn (void);

PRESENCE ActiveIfEpcInlet (void);
PRESENCE IfAnyAux (void);
PRESENCE IfFrontInlet (void);
PRESENCE IfBackInlet (void);
PRESENCE IfFrontDet (void);
PRESENCE IfBackDet (void);
PRESENCE IfConfigDet (void);
PRESENCE IfPneuAux (void);
PRESENCE IfFrontBack (void);  /* For front and back det BOTH present */
PRESENCE IfFrEpcInlet (void);
PRESENCE IfBkEpcInlet (void);
PRESENCE IfFrDetDiag1 (void);
PRESENCE IfFrDetDiag2 (void);
PRESENCE IfBkDetDiag1 (void);
PRESENCE IfBkDetDiag2 (void);
PRESENCE IfEpc(void);
PRESENCE IfNoEpc(void);

/* r_configcol.c */
PRESENCE IfMakeupGas( POSITION pos );
PRESENCE IfFrontDetMakeup (void);
PRESENCE IfBackDetMakeup (void);

void ReturnToCalibLine (void);
void ReturnToCommLine (void);
void ReturnToDiagLine (void);
void ReturnToFrInletCalLine (void);
void ReturnToBkInletCalLine (void);
void ReturnToCol1CalLine (void);
void ReturnToCol2CalLine (void);
void ReturnToFrDetCalLine (void);
void ReturnToBkDetCalLine (void);
void ReturnToAuxCalLine (void);

U_INT32   GetDetDiag1SelMsg ( POSITION position);
U_INT32   GetDetDiag2SelMsg ( POSITION position);

/* r_det.c */
void EnterECDReference (void);
void ECDReferenceLine (LINE line);
void ECDReferenceInfo (void);

/* kbd_util.c */
U_INT16 GetDetGas1Msg( POSITION position, U_INT16 msg_type );
U_INT16 GetDetGas2Msg( POSITION position, U_INT16 msg_type );
U_INT16 GetDetGas3Msg( POSITION position, U_INT16 msg_type );
U_INT16 GetRTTSignalDefMsg( INT32 def );

/* r_prog.c, for John's INET method listing */
void    TypeLine (U_INT8 type, LINE line);
void    ValueLine (U_INT8 type, INT32 parm, LINE line);

#pragma SECTION UNDO

#pragma SECTION PROG=keybd

void RuleClockProg (void);
void RuleClockTblOnOff (void);
void RuleClockTblMode (void);
void RuleClockTblFrontBack(void);
void RuleConfig (void);
void RuleConfigStatus (void);
void RuleDeviationsDisplay (void);
void RuleLoadStore(void);
void RuleWhatMethod(void);
void RuleMethod(void);
void RuleEnterMethod(void);
void RuleDefaultEnter(void);
void RuleSetDefaults(void);
void RuleSeqStore (void);
void RuleEnterSeq (void);
void RuleWhatSeq (void);

void GoToMethod (U_INT8 method);
void GoToSeq (U_INT8 seq);

void LoadInfo (void);
void StoreInfo (void);

void StatusDisplay (LINE line);

PRESENCE StatusPresence (void);
PRESENCE IfSwitchValve (void);
PRESENCE IfMultiValve (void);

void ReturnToOvenLine (void);
void ReturnToFrInletLine (void);
void ReturnToBkInletLine (void);
void ReturnToColumn1Line (void);
void ReturnToColumn2Line (void);
void ReturnToFrDetLine (void);
void ReturnToBkDetLine (void);
void ReturnToSig1Line (void);
void ReturnToSig2Line (void);
void ReturnToAuxLine (void);
void ReturnToStatusLine (void);
void ReturnToTimeLine (void);
void ReturnToValveLine (void);
void ReturnToFrInjectorLine (void);
void ReturnToBkInjectorLine (void);
void ReturnToTrayLine (void);
void ReturnToConfigLine (void);

#pragma SECTION UNDO

#endif
